using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

namespace JufGame
{
	[CustomEditor(typeof(TestItem))]
	public class TestItem_Editor : Editor
	{
		TestItem testItem;
		SerializedProperty start;
		SerializedProperty trackPoint;
		SerializedProperty end;
		SerializedProperty isShowPath;
		MonoScript script;

		private void OnEnable()
		{
			testItem = target as TestItem;
			
			start = serializedObject.FindProperty("start");
			trackPoint = serializedObject.FindProperty("trackPoint");
			end = serializedObject.FindProperty("end");
			isShowPath = serializedObject.FindProperty("isShowPath");

			script = MonoScript.FromMonoBehaviour(target as MonoBehaviour);
		}

		public override void OnInspectorGUI()
		{
			EditorGUILayout.BeginVertical();
			serializedObject.Update();

			EditorGUI.BeginDisabledGroup(true);
			EditorGUILayout.ObjectField("脚本", script, typeof(MonoScript), true);
			EditorGUI.EndDisabledGroup();

			EditorGUILayout.PropertyField(start, new GUIContent("start"));
			EditorGUILayout.Space(0.5f);
			EditorGUILayout.PropertyField(trackPoint, new GUIContent("trackPoint"));
			EditorGUILayout.Space(0.5f);
			EditorGUILayout.PropertyField(end, new GUIContent("end"));
			EditorGUILayout.Space(0.5f);
			EditorGUILayout.PropertyField(isShowPath, new GUIContent("显示路径"));
			EditorGUILayout.Space(0.5f);
			
			if(GUILayout.Button("进行一次A星搜索"))
			{
				testItem.ButtonTest();
			}
			EditorGUILayout.Space(0.5f);
			if(GUILayout.Button("追踪一次路径"))
			{
				testItem.TrackPath();
			}

			serializedObject.ApplyModifiedProperties();
			EditorGUILayout.EndVertical();
		}
	}
}
